package com.micangcaihang.micang.mvp.task.model;

import com.micangcaihang.common.baserx.RxSchedulers;
import com.micangcaihang.common.http.ApiResult;
import com.micangcaihang.common.http.RxHelper;
import com.micangcaihang.micang.entity.TaskPriceSurveyEntity;
import com.micangcaihang.micang.http.ApiService;
import com.micangcaihang.micang.mvp.task.contract.TaskPriceSurveyContract;

import io.reactivex.Observable;

/**
 * <pre>
 *     author : Fandy
 *     e-mail : fandayongfly@gmail.com
 *     time   : 2017/07/17
 *     desc   : 价格调查
 *     version: 1.0
 * </pre>
 */

public class TaskPriceSurveyModel implements TaskPriceSurveyContract.Model {
    /**
     * 获取价格调查数据
     *
     * @param id
     * @return
     */
    @Override
    public Observable<ApiResult<TaskPriceSurveyEntity>> getPriceSurveyData(String id) {
        return ApiService.<ApiResult<TaskPriceSurveyEntity>>invest_priceSurvey(id)
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 保存信息
     *
     * @param request
     * @return
     */
    @Override
    public Observable<ApiResult<Void>> savaPriceSurveyData(TaskPriceSurveyEntity request) {
        return null;
    }

    /**
     * 保存新楼信息
     *
     * @param request
     * @return
     */
    @Override
    public Observable<ApiResult<Void>> savaXinlouData(TaskPriceSurveyEntity request) {
        return ApiService.<ApiResult<Void>>invest_xinlouupdate(request)
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 保存中介信息
     *
     * @param request
     * @return
     */
    @Override
    public Observable<ApiResult<Void>> savaZhongJieData(TaskPriceSurveyEntity request) {
        return ApiService.<ApiResult<Void>>invest_zhongjieupdate(request)
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }

    /**
     * 删除价格
     *
     * @param id
     * @param evaluate_id
     * @return
     */
    @Override
    public Observable<ApiResult<Void>> deletePriceData(String id, String evaluate_id) {
        return ApiService.<ApiResult<Void>>invest_pricesurveydelete(id, evaluate_id)
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }
}
